-
-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: TF_CLI_ARGS_*
Handling
#898
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughThe pull request enhances the handling of Terraform command-line arguments and environment variables within the Atmos shell utility functions. It introduces a structured approach for managing Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
internal/exec/terraform.go (1)
262-264
: Catching var-file collisions in component environment ensures thorough coverage.
These lines do a great job of warning users when environment-level settings might be overridden.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
internal/exec/shell_utils.go
(1 hunks)internal/exec/terraform.go
(1 hunks)
🔇 Additional comments (4)
internal/exec/shell_utils.go (3)
188-190
: Neat definition of terraform commands.
This approach centralizes the commands that may require var-file handling, simplifying future maintenance and extension.
191-197
: Clear warning message for potential collisions.
It is helpful to log a warning whenever these TF_CLI_ARGS variables contain a “-var-file” argument, reducing user confusion.
198-200
: Appending the var file reference to each command is straightforward.
Ensure users understand that this logic overrides any existing “-var-file” specification at runtime.
internal/exec/terraform.go (1)
248-257
: Collisions detection is consistent with shell_utils.
Capturing conflicts across both the shell and terraform commands maintains consistent user visibility.
Here's the misunderstanding.
Here are the new requirements
|
internal/exec/terraform.go
Outdated
for _, cmd := range tfCommands { | ||
envVar := fmt.Sprintf("TF_CLI_ARGS_%s", cmd) | ||
existing := os.Getenv(envVar) | ||
if existing != "" && strings.Contains(existing, "-var-file=") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace this behavior. Check for any "TF_" prefixed env var and give a warning. Do not emit the value, but do emit the name of the variable
internal/exec/shell_utils.go
Outdated
u.LogWarning(atmosConfig, "Found var-file in environment! This may be overwritten by Atmos") | ||
} | ||
// Set the Terraform environment variable to reference the var file | ||
componentEnvList = append(componentEnvList, fmt.Sprintf("%s=-var-file=%s", envVar, varFile)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead append Atmos settings to any TF_CLI_ARGS_*. Atmos takes precedence.
internal/exec/terraform.go
Outdated
if strings.Contains(v, "-var-file=") { | ||
u.LogWarning(atmosConfig, "Found var-file in component environment! This may be overwritten by Atmos") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirm this isnt processed twice. We should already have merged the env vars before running this function altogether
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace with if the value starts with TF_CLI, print warning message
TF_CLI_ARGS_*
Handling for -var-file
TF_CLI_ARGS_*
Handling
what
TF_CLI_ARGS_*
environment variable for-var-file
, since this may conflict with Atmos generated var files.terraform shell
,terraform
as a ENV var,terraform
as a componentenv
varwhy
references
Summary by CodeRabbit
New Features
-var-file
arguments to respect existing configurations.Bug Fixes